﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace VMWareLabWorkflowsDataContracts.VMWareLabDetailsDialogControls
{
    using Microsoft.TeamFoundation.Client;
    using Microsoft.TeamFoundation.Lab.Workflow.Activities;
    using Microsoft.TeamFoundation.TestManagement.Client;

    using VMWareLabWorkflowsDataContracts.VMWareLabDetailsDialogControls.ViewModel;

    /// <summary>
    /// Interaction logic for TestDetailsControl.xaml
    /// </summary>
    public partial class TestDetailsControl : UserControl
    {
        public TestDetailsViewModel TestDetailsViewModel { get; set; }
        public TestDetailsControl()
        {
            InitializeComponent();
            this.TestDetailsViewModel = new TestDetailsViewModel();
            this.DataContext = this.TestDetailsViewModel;
        }

        /// <summary>
        /// Handles the SelectionChanged event of the cbTestPlan control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Controls.SelectionChangedEventArgs"/> instance containing the event data.</param>
        private void cbTestPlan_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            this.TestDetailsViewModel.GetTestSuitesForTestPlan(((ITestPlan)this.cbTestPlan.SelectedItem).Name);
        }

        /// <summary>
        /// Handles the SelectionChanged event of the cbTestConfiguration control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Controls.SelectionChangedEventArgs"/> instance containing the event data.</param>
        private void cbTestConfiguration_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            this.TestDetailsViewModel.TestDetails.TestConfigurationId =
                ((ITestConfiguration)this.cbTestConfiguration.SelectedItem).Id;
        }

    }
}
